unit HeadWidget;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  Vcl.Buttons, MenuButton, Vcl.ExtCtrls, Vcl.Menus,
  Vcl.Imaging.pngimage;

type
  TfrHead = class(TFrame)
    frMenuButton1: TfrMenuButton;
    frMenuButton2: TfrMenuButton;
    frMenuButton3: TfrMenuButton;
    Panel3: TPanel;
    Image1: TImage;
    btnUser: TSpeedButton;
    pnMenuS: TPanel;
    imgButton: TImage;
    PMHead: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    procedure imgButtonClick(Sender: TObject);
    procedure imgButtonMouseEnter(Sender: TObject);
    procedure imgButtonMouseLeave(Sender: TObject);
    procedure btnUserClick(Sender: TObject);
    procedure N2Click(Sender: TObject);
  private
    imagename: string;
    { Private declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  end;

implementation

uses
  MsgWidget;

{$R *.dfm}

constructor TfrHead.Create(AOwner: TComponent);
begin
  inherited;
  imagename := 'menuin';
  imgButton.Picture.LoadFromFile(imageFile(imagename));
end;

procedure TfrHead.imgButtonClick(Sender: TObject);
begin
  if (imagename = '') or (imagename = 'menuin') then
  begin
    imagename := 'menuout';
  end
  else
  begin

    imagename := 'menuin';
  end;
  imgButton.Picture.LoadFromFile(imageFile(imagename));
  SendMessage(MainFromHande, WM_MENUSHOW_MSG, 0, Integer(PChar(imagename)));
end;

procedure TfrHead.imgButtonMouseEnter(Sender: TObject);
begin
  self.pnMenuS.Color := $00453426;
end;

procedure TfrHead.imgButtonMouseLeave(Sender: TObject);
begin
  self.pnMenuS.Color := $00564110;
end;

procedure TfrHead.N2Click(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TfrHead.btnUserClick(Sender: TObject);
begin
  PMHead.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
end;

end.

